<script>
import { useUserStore } from './stores/user'
import { useFilesStore } from './stores/files'

export default {
	onLaunch: async function () {
		const userStore = useUserStore()

		// 只检查登录状态
		await userStore.checkLogin()
	},

	onShow: function () {
		console.log('App Show 123')
		// 每次显示小程序时，跳转到首页
		const pages = getCurrentPages()
		if (
			pages.length === 0 ||
			pages[pages.length - 1].route !== 'pages/study/study'
		) {
			uni.switchTab({
				url: '/pages/study/study'
			})
		}
	},

	onHide: function () {
		console.log('App Hide  123')
	},

	// 全局分享设置
	globalData: {
		share: {
			title: 'A*俱乐部 - 爱德思题库',
			path: '/pages/study/study',
			imageUrl: '/static/images/logo.png'
		}
	},

	// 全局分享到好友
	onShareAppMessage() {
		const shareInfo = this.globalData.share
		return {
			title: shareInfo.title,
			path: shareInfo.path,
			imageUrl: shareInfo.imageUrl
		}
	},

	// 全局分享到朋友圈
	onShareTimeline() {
		const shareInfo = this.globalData.share
		return {
			title: shareInfo.title,
			path: shareInfo.path,
			imageUrl: shareInfo.imageUrl
		}
	}
}
</script>

<style>
/*每个页面公共css */
</style>
